﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Validation;
//using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace Grebok.Domain
{
    public class DomainObject : IValidableObject
    {
        public virtual bool IsValid
        {
            get
            {
                try
                {
                    return this.Validate().IsValid;
                }
                catch
                {
                    return false;
                }
            }
        }

        public virtual ValidationResults Validate()
        {
            Validator validator = ValidationFactory.CreateValidator(this.GetType());
            ValidationResults results = new ValidationResults();
            validator.Validate(this, results);
            return results;
        }
    }
}
